package com.mail.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mail.dubbo.mapper.OmsOrderOperateHistoryMapper;
import com.mail.model.db.OmsOrderOperateHistory;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService
public class OrderOperateHistoryApiImpl implements OrderOperateHistoryApi {

    @Autowired
    private OmsOrderOperateHistoryMapper orderOperateHistoryMapper;

    //根据订单id查询订单操作历史记录
    public List<OmsOrderOperateHistory> findOperateHistory(Long orderId) {
        QueryWrapper<OmsOrderOperateHistory> qw = new QueryWrapper<>();
        qw.eq("order_id", orderId);
        return orderOperateHistoryMapper.selectList(qw);
    }

    //批量保存订单操作历史记录
    public void save(List<OmsOrderOperateHistory> historyList) {
        for (OmsOrderOperateHistory history : historyList) {
            orderOperateHistoryMapper.insert(history);
        }
    }

    //保存指定的订单操作历史记录
    public Integer saveOne(OmsOrderOperateHistory history) {
        return orderOperateHistoryMapper.insert(history);
    }
}
